package com.gaussian.property.admin.module.biz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gaussian.property.admin.module.biz.service.SuggestService;
import com.gaussian.property.admin.module.biz.vo.suggest.ReplyForm;
import com.gaussian.property.admin.module.biz.vo.suggest.SuggestReplyVo;
import com.gaussian.property.module.biz.entity.AppUser;
import com.gaussian.property.module.biz.vo.suggest.PageQueryProjectSuggestRequest;
import com.gaussian.property.module.biz.vo.suggest.PageQueryProjectSuggestResponse;
import com.songqi.common.core.domain.R;
import com.songqi.common.core.domain.page.PageDataInfo;
import com.songqi.common.web.request.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @author: songqi(13776346982)
 * @date: 2024/4/18 21:41
 */
@Api(tags = "项目建议相关操作")
@Validated
@RestController
@RequestMapping("suggest/")
public class SuggestController extends BaseController {


    @Resource
    private SuggestService suggestService;


    @ApiOperation("分页查询项目建议")
    @GetMapping("pageQueryProjectSuggest")
    public R<PageDataInfo<PageQueryProjectSuggestResponse>> pageQueryProjectSuggest(PageQueryProjectSuggestRequest queryRequest) {
        IPage<PageQueryProjectSuggestResponse> pageData = suggestService.pageQueryProjectSuggest(queryRequest);
        return getReturnDataTableInfo(pageData);
    }


    @ApiOperation("查询建议的回复列表")
    @GetMapping("querySuggestionReply")
    public R<List<SuggestReplyVo>> querySuggestionReply(@ApiParam("项目建议id") String projectSuggestionId){
        return R.success(suggestService.querySuggestionReply(projectSuggestionId));
    }

    @ApiOperation("提交回复")
    @PostMapping("submitReply")
    public R<Void> submitReply(@Validated @RequestBody ReplyForm replyForm){
        suggestService.submitReply(replyForm);
        return R.success();
    }


    @ApiOperation("删除回复")
    @PostMapping("deleteReply/{projectSuggestionReplyId}")
    public R<Void> deleteReply(@PathVariable String projectSuggestionReplyId){
        suggestService.deleteReply(projectSuggestionReplyId);
        return R.success();
    }

}
